package com.zuosh.common;

/**
 * Created by zuoshuai on 2017/3/3.
 */
public class Result<T> {
    private String code = ResponseCode.SUCCESS;
    private String msg;
    private T data;

    public Result(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(T data, String msg) {
        this.msg = msg;
        this.data = data;
    }

    /**
     * 是否成功
     *
     * @return
     */
    public boolean isSuccess() {
        return this.code.equalsIgnoreCase(ResponseCode.SUCCESS);
    }

    public Result setResult(String code, T data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
        return this;
    }

    public Result() {
    }

    public static <T> Result buildResult(String code, String msg, T t) {
        return new Result(code, msg, t);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
